using System.Collections.Generic;
using JetBrains.Annotations;
using com.adjust.sdk;

namespace Voodoo.Sauce.Internal.Analytics
{
	internal class AdjustAnalyticsEvent : BaseAnalyticsEvent
	{
		[CanBeNull]
		private Dictionary<string, object> _parameter;

		protected override string GetAnalyticsProviderName()
		{
			return "Adjust";
		}

		public AdjustAnalyticsEvent(string eventName, [CanBeNull] Dictionary<string, object> parameter)
			: base(eventName)
		{
			_parameter = parameter;
		}

		protected override void PerformTrackEvent()
		{
			AdjustEvent adjustEvent = new AdjustEvent(base.EventName);
			if (_parameter != null)
			{
				foreach (KeyValuePair<string, object> item in _parameter)
				{
					adjustEvent.addCallbackParameter(item.Key, item.Value.ToString());
					adjustEvent.addPartnerParameter(item.Key, item.Value.ToString());
				}
			}
			Adjust.trackEvent(adjustEvent);
		}
	}
}
